<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:c="http://java.sun.com/jsp/jstl/core"
	xmlns:p="http://primefaces.org/ui" >
		    
	<h:form id="frm0" > 
		<h:panelGrid columns="6" cellspacing="10" >	
			<p:outputLabel value="合同编号" />
			<p:inputText  value="#{contractMB.contractId}" />
			<p:outputLabel value="合同名称" />
			<p:inputText value="#{contractMB.contractName}" />
            <p:commandButton value="查询合同"	icon="ui-icon-search"  
				action="#{contractMB.queryAction}"  update=":frm1 :frm2 :frm3 :frmAttach">
			</p:commandButton>		
		</h:panelGrid>
	</h:form>

	<h:form id="frm1">
		<p:growl id="msgs1" showDetail="true" />
		<p:panel id="contPanel" header="【第一步】合同信息录入【在录入信息后一定要保存后再进行其他后续操作】" style="margin-bottom:5px" >
		
			<h:panelGrid columns="4" cellspacing="10">		
				<p:commandButton value="新增合同" icon="ui-icon-plus" 
	           		process="@this" update=":frm0 :frm1 :frm2 :frm3 :frmAttach"
                 	actionListener="#{contractMB.onAddContract}" />	
				<p:commandButton value="保存合同"	icon="ui-icon-check" 
					action="#{contractMB.saveAction}" update=":frm1:msgs1 :frm2 ">
				</p:commandButton>	
				<p:commandButton value="提交审核"	icon="ui-icon-pencil"  immediate="true"
					action="#{contractMB.checkWfmAction}" update=":frm1:msgs1">
				</p:commandButton>
				<p:commandButton value="提交变更"	icon="ui-icon-pencil"  immediate="true"
					action="#{contractMB.updateWfmAction}" update=":frm1:msgs1">
				</p:commandButton>
			</h:panelGrid>
			
			<h:panelGrid columns="10" cellspacing="10" >	
				<p:outputLabel value="项目名称" />
				<p:inputText value="#{contractMB.io.pname}" />	

		        <p:outputLabel value="客户名称:" for="custObject" />
		        <p:autoComplete id="custObject" value="#{contractMB.selectedCustomer}" completeMethod="#{contractMB.completeCustomers}"
		                        var="autoCust" itemLabel="#{autoCust.name}" itemValue="#{autoCust}" 
		                        converter="bmeCustomerConverter" forceSelection="true"  		                        
		                        dropdown="true"  required="true" requiredMessage="客户编号必须输入" >
		             <p:ajax event="itemSelect" listener="#{contractMB.onAutoSelect}" update=":frm1:pcustCity :frm1:msgs1" /> 
		        </p:autoComplete>
                        												    	
				<p:outputLabel value="客户城市" />				
				<p:inputText id="pcustCity" value="#{contractMB.io.custCity}" disabled="true" />	

				<p:outputLabel value="合同编号" />
				<p:inputText  value="#{contractMB.io.id}" required="true" requiredMessage="合同编号必须输入"/>
				<p:outputLabel value="合同名称" />
				<p:inputText value="#{contractMB.io.name}" required="true" requiredMessage="合同名称必须输入"/>
						        
				<p:outputLabel value="项目经理" />
				<p:selectOneMenu value="#{contractMB.io.pm}" effect="fold" style="width:80%;" 
					required="true" requiredMessage="项目经理必须输入" filterMatchMode="startsWith" filter="true">
					<f:selectItem itemLabel="选择..." itemValue="" noSelectionOption="true" />
					<f:selectItems value="#{contractMB.itemsSysUsers}" />
				</p:selectOneMenu>
				
				<p:outputLabel value="大区经理" />
				<p:selectOneMenu value="#{contractMB.io.regionMgr}" effect="fold" style="width:80%;" 
					required="true" requiredMessage="内务必须输入" filterMatchMode="startsWith" filter="true" >
					<f:selectItem itemLabel="选择..." itemValue="" noSelectionOption="true" />
					<f:selectItems value="#{contractMB.itemsSysUsers}" />
				</p:selectOneMenu>
				<p:outputLabel value="内务" />
				<p:selectOneMenu value="#{contractMB.io.interior}" effect="fold" style="width:80%;" 
					required="true" requiredMessage="内务必须输入" filterMatchMode="startsWith" filter="true" >
					<f:selectItem itemLabel="选择..." itemValue="" noSelectionOption="true" />
					<f:selectItems value="#{contractMB.itemsSysUsers}" />
				</p:selectOneMenu>
																
				<p:outputLabel value="供应商" />
				<p:selectOneMenu value="#{contractMB.io.supplierId}"  effect="fold" style="width:80%;" 
					required="true" requiredMessage="供应商必须输入" filterMatchMode="startsWith" filter="true" >
					<f:selectItem itemLabel="选择..." itemValue="" noSelectionOption="true"  />
					<f:selectItems value="#{contractMB.itemsSuppliers.entrySet()}" var="entry"
						itemValue="#{entry.key}" itemLabel="#{entry.value}" />
				</p:selectOneMenu>
				
				<p:outputLabel value="收货地址" />
				<p:inputText value="#{contractMB.io.shippingAddress}" />	
				
				<p:outputLabel value="施工方" />
				<p:inputText value="#{contractMB.io.construct}" />	
				
				<p:outputLabel value="合同日期" />
				<p:calendar id="signDate" locale="zh" navigator="true"  value="#{contractMB.io.signDate}" 
					pattern="yyyy-MM-dd" mask="true"  mode="popup"	showOn="button" popupIconOnly="true"
					required="true" requiredMessage="合同日期必须输入" />
				
				<p:outputLabel value="合同状态" />
				<p:selectOneMenu value="#{contractMB.io.status}" effect="fold" style="width:80%;" 
					required="true" requiredMessage="类别必须输入" disabled="true">
					<f:selectItem itemLabel="选择..." itemValue="" noSelectionOption="true" />
					<f:selectItems value="#{contractMB.itemsContractStatus}" />
				</p:selectOneMenu>				
				
				<p:outputLabel value="合同金额" />
				<p:inputText id="pContractPrice" value="#{contractMB.io.price}" disabled="true" />	
				
				<p:outputLabel value="备注" />
				<p:inputText value="#{contractMB.io.remarks}" />	
									
			</h:panelGrid>				
		</p:panel>    
	</h:form>
	
	<h:form id="frmAttach" > 	
		<p:growl id="msgsAttach" showDetail="true" />		
		<p:panel id="panelAttached" header="附件信息上传" toggleable="true" toggleSpeed="500" 
			 style="margin-bottom:10px" collapsed="true"> 
			<p:ajax event="toggle" listener="#{attachUploadMB.onToggle}" update="frmAttach" />
			<!-- 页面间参数传递 -->
			<ui:include src="bme_attach_upload.xhtml">
			     <ui:param name="uploadForType" value="#{contractMB.uploadForType}" />
			     <ui:param name="uploadForId" value="#{contractMB.uploadForId}" />
			     <ui:param name="uploadForName" value="#{contractMB.uploadForName}" />
			</ui:include>
        </p:panel>
	</h:form>
				
</ui:composition>
